

const work = function (age, area) {
    console.log(this.name, age, area, "is work");
}

// work();

// const obj = {
//     name: "eric",
//     work
// }

// obj.work();

Function.prototype.myCall = function (target, ...params) {
    target.func = this;
    target.func(...params);
    delete this.func;
}

const obj = {
    name: "eric"
};

// work.myCall(obj);
// work.myCall(obj, 19, "shenzhen");



Function.prototype.myApply = function (target, params) {
    target.func = this;
    target.func(...params);
    delete target.func;
}

work.myApply(obj, [22, "xxxxr"]);
// work([22, "xxxxr"]);